package com.link.base.base.inventmanage.controller;


import com.link.base.base.inventmanage.model.InventoryManagement;
import com.link.base.base.inventmanage.service.InventoryManagementService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author: Huanglj
 * created: 2018/4/17
 * comments: 处理关于产品库存的请求
 */
@Controller
@RequestMapping("/link/inventoryManagement")
public class InventoryManagementController extends BasicController<InventoryManagement> {

    @Resource
    private InventoryManagementService inventoryManagementService;

    @Override
    public BasicService<InventoryManagement> getBasicService() throws Exception {
        return inventoryManagementService;
    }

    @RequestMapping(value = "/queryByAccntId", method = RequestMethod.POST)
    @ResponseBody
    Map<String, Object> queryByAccntId(@RequestBody InventoryManagement inventoryManagement) {
        Map<String, Object> result = new HashMap<String, Object>();
        try {
            List<InventoryManagement> retList = inventoryManagementService.queryByAccntId(inventoryManagement);
            result.put("success", true);
            result.put("inventoryManagement", retList);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
